<script>
  var data = [
    ["2023-10-01 00:00:00", 10],
    ["2023-10-01 01:00:00", 20],
    ["2023-10-01 02:00:00", 30],
    ["2023-10-01 03:00:00", 40],
    ["2023-10-01 04:00:00", 50],
    ["2023-10-01 05:00:00", 60],
    ["2023-10-01 06:00:00", 70],
    ["2023-10-01 07:00:00", 80],
    ["2023-10-01 08:00:00", 90],
    ["2023-10-01 09:00:00", 100],
    ["2023-10-01 10:00:00", 110],
    ["2023-10-01 11:00:00", 120],
    ["2023-10-01 12:00:00", 130],
    ["2023-10-01 13:00:00", 140], 
    ["2023-10-01 14:00:00", 150],
    ["2023-10-01 15:00:00", 160],
    ["2023-10-01 16:00:00", 170],
    ["2023-10-01 17:00:00", 180],
    ["2023-10-01 18:00:00", 190],
    ["2023-10-01 19:00:00", 200],
    ["2023-10-01 20:00:00", 210],
    ["2023-10-01 21:00:00", 220],
    ["2023-10-01 22:00:00", 230],
    ["2023-10-01 23:00:00", 240],
  ];

  // 处理数据，提取时间和值
  var times = data.map(function (item) {
    return item[0];
  });
  var values = data.map(function (item) {
    return item[1];
  });

  // 定义 x 轴分隔线间隔的函数

  // 指定图表的配置项和数据
  var option = {
    title: {
      text: "在固定索引位置显示分隔线",
    },
    tooltip: {
      trigger: "axis",
    },
    xAxis: {
      type: "category",
      data: times,
      splitLine: {
        show: true,
        interval: (index) => {
          return [2, 3].includes(index);
        },
      },
    },
    yAxis: {
      type: "value",
    },
    series: [
      {
        name: "数据",
        type: "line",
        data: values,
      },
    ],
  };
</script>
